<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class Article extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'cate_id' => 'required|integer',
            'article_title'=>'required|min:5',
            'read_num'=>'integer',
            'article_status' => 'required|in:1,2',
            'is_recom' => 'required|in:1,2',
            'article_content'=>'required|min:10',
        ];
    }

    public function messages(): array
    {
        return [
            'cate_id.required' => '分类ID不能为空',
            'cate_id.integer' => '分类ID值必须是整数',

            'article_title.required' => '文章标题不能为空',
            'article_title.min' => '文章标题不能少于5个字符',

            'read_num.integer' => '阅读数必须是整数',

            'article_status.required' => '状态不能为空',
            'article_status.in' => '状态值只能是1或者2',

            'is_recom.required' => '推荐值不能为空',
            'is_recom.in' => '推荐值只能是1或者2',

            'article_content.required' => '文章内容不能为空',
            'article_content.min' => '文章内容不能少于10个字符',




        ];
    }
}
